<?php
include('Album.php');
	$listAlbum=array();
    $first='http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&format=json&artist=';
	$key='&api_key=2e0f6a31b6598dae0585ac68964d579c';
    $artist='eddie%20money';
    $url=$first.$artist.$key;
	
	$html=  file_get_contents($url,true);
    $json=  json_decode($html,true);
    $albumname='';
	$albumcoverlink='';
     
	/*$albumname=$json['topalbums']['album'][0]['name'];
	$albumlink=$json['topalbums']['album'][0]['image'][3]['#text'];
	
	print_r($albumname);
	print_r($albumlink);*/
	
	$array=$json['topalbums']['album'];
	$albumname=array();
	foreach($array as $item){
		$newAlbum=new Album();
		$newAlbum->setName($item['name']);
		$newAlbum->setCover($item['image'][3]['#text']);
		array_push($listAlbum,$newAlbum);	
	}
	

	
	
	$page;
	$page=$json['topalbums']['@attr']['totalPages'];
	
	
	
	for ($i = 2; $i <=$page; $i++) {
		
	$first='http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&format=json&page='.$i.'&artist=';
	$key='&api_key=2e0f6a31b6598dae0585ac68964d579c';
    $artist='eddie%20money';
    $url=$first.$artist.$key;
	
	$html=  file_get_contents($url,true);
    $json=  json_decode($html,true);
    $array=$json['topalbums']['album'];
	foreach($array as $item){
		$newAlbum=new Album();
		$newAlbum->setName($item['name']);
		$newAlbum->setCover($item['image'][3]['#text']);
		array_push($listAlbum,$newAlbum);	
		
	
	
}}
	for($i=0;$i<count($listAlbum);$i++){
		print($listAlbum[$i]->toString()."<br>");
	}

	?>